<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        position: absolute;
        height: 200px;
        width: 200px;
        border: 1px solid red;
      }
      .hiden {
        display: none;
      }
    </style>
  </head>
  <body>
    <div id="box">
      <h2>点赞</h2>
      <p>收藏</p>
    </div>

    <script>
      var boxEle = document.getElementById('box');
      document.addEventListener('contextmenu', function (event) {
        // console.log('hah');
        // event.preventDefault();
        // boxEle.classList.remove('hiden');
        // boxEle.style.left = event.clientX + 'px';
        // boxEle.style.top = event.clientY + 'px';
      });
      document.addEventListener('click', function () {
        // console.log('hid');
        boxEle.classList.add('hiden');
      });
      boxEle.addEventListener('click', function (event) {
    
      });
      boxEle.onclick = function (event) {
        var nodeName = event.target;
        console.log(nodeName)
      };
     
    </script>
  </body>
</html>
